<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 类首字母大写；  注意写constrictor函数；  生成实例new不能省
        // 创建一个类 class 
        class Student {
            constructor(uname, age, sex) {
                this.uname = uname
                this.age = age
                this.sex = sex
            }
            // 添加公有方法
            sing(song){
                console.log(this.uname + song);
            }
        }

        // 创造对象
        const stu1 = new Student('李四', 18, '男')
        const stu2 = new Student('张三', 20, '女')
        console.log(stu1, stu2);
        stu1.sing('登峰造极')
        stu2.sing('一起摇摆')
    </script>
</body>

</html>